import axios from 'axios'

const ServerAddress = "http://localhost:5000"

export async function doPost(api, params) {
    const response = await axios.post(api,params,{
        baseURL: ServerAddress,
        headers: { 'Content-Type': 'application/json;utf-8' },
    })
    const { status } = response
    if (status === 200) {
        // 返回json数据
        const apiData =  response.data
        // 请求成功
        if (apiData.code === 200) {
            return apiData.data
        }
        const msg = apiData.msg
        console.log(`接口${api}出错${msg}`);
    }
    console.log(response);
    console.log(`接口${api}通信出错`);
    return null
}